﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using C.Entities;

namespace C.Unite
{
    /// <summary>
    /// 取得网站COOKIES信息
    /// </summary>
    public class CookInfo
    {
        #region 取得所有COOKIES信息
        /// <summary>
        /// 取用户ID
        /// </summary>
        /// <returns></returns>
        public static int EAdminid()
        {
            int uid = 0;
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                uid = int.Parse(DesHelper.DecryptDES(HttpContext.Current.Request.Cookies[cookname]["Uid"].ToString(), DesKeys.myKey));
            }
            return uid;
        }



        /// <summary>
        /// 取HREMPID
        /// </summary>
        /// <returns></returns>
        public static int EEmpID()
        {
            int uid = 0;
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                uid = int.Parse(HttpContext.Current.Request.Cookies[cookname]["HREmpID"].ToString());
            }
            return uid;
        }

        /// <summary>
        /// 用户所属组
        /// </summary>
        /// <returns></returns>
        public static int EAdminGroupId()
        {
            int uid = 0;
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                uid = int.Parse(DesHelper.DecryptDES(HttpContext.Current.Request.Cookies[cookname]["NewGroupID"].ToString(), DesKeys.mygroupKey));
            }
            return uid;
        }
        /// <summary>
        /// 用户组角色
        /// </summary>
        /// <returns></returns>
        public static string EAdminGroupFlag()
        {
            string groupflag = "";
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                groupflag = HttpContext.Current.Request.Cookies[cookname]["GroupFlag"].ToString();
            }
            return groupflag;
        }

        /// <summary>
        /// 用户上次登录时间
        /// </summary>
        /// <returns></returns>
        public static string EAdminPevTime()
        {
            string groupflag = "";
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                groupflag = HttpContext.Current.Request.Cookies[cookname]["PevTime"].ToString();
            }
            return groupflag;
        }

        /// <summary>
        /// 用户组名称
        /// </summary>
        /// <returns></returns>
        public static string EAdminGroupName()
        {
            string groupflag = "";
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                groupflag = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[cookname]["GroupName"].ToString());
            }
            return groupflag;
        }
        /// <summary>
        /// 用户真实姓名
        /// </summary>
        /// <returns></returns>
        public static string EAdminTrueName()
        {
            string groupflag = "";
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                groupflag = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[cookname]["TrueName"].ToString());
            }
            return groupflag;
        }

        /// <summary>
        /// 员工编号
        /// </summary>
        /// <returns></returns>
        public static string EAdminEmpID()
        {
            string groupflag = "";
            string cookname = ConfigHelper.GetWebConfigPath("LoginCookGroup");
            if (HttpContext.Current.Request.Cookies[cookname] != null)
            {
                groupflag = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[cookname]["EmpID"].ToString());
            }
            return groupflag;
        }

        #endregion
    }
}